package com.example.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.adapter.TabVpiAdapter;
import com.example.fruit.R;
import com.lidroid.xutils.HttpUtils;
import com.viewpagerindicator.TabPageIndicator;


import java.util.ArrayList;
import java.util.List;



public class GuoshiFragment extends Fragment {


    private TabPageIndicator tabPageIndicator;

    private ViewPager viewPager;

    private TabVpiAdapter adapter;
    private  String titles[]={"百科","果园"};
    private List<Fragment> fragmentList = new ArrayList<Fragment>();
    private HttpUtils httpUtils;
    private View views;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        httpUtils=new HttpUtils();
       fragmentList.add(new BaiKeFragment());
       fragmentList.add(new GuoYouQuanFragment());

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
         views=inflater.inflate(R.layout.fragment_guoshi, container, false);
        return views;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        adapter = new TabVpiAdapter(fragmentList, getFragmentManager(),titles);
        viewPager = (ViewPager) views.findViewById(R.id.goushi_viewpager);
        viewPager.setAdapter(adapter);
        tabPageIndicator = (TabPageIndicator) views.findViewById(R.id.guoshi_vpi_tbi);
        tabPageIndicator.setViewPager(viewPager);

    }


}
